package com.clip.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.clip.entity.UserRegInvites;

@Repository
public class UserRegInvitesDAO extends BasicDao {

	private static final Log log = LogFactory.getLog(UserRegInvites.class);

	public Integer save(UserRegInvites transientInstance) {
		int id = 0;
		log.debug("saving UserRegInvites instance");
		try {
			id = (Integer) getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
		return id;
	}

	public void delete(UserRegInvites persistentInstance) {
		log.debug("deleting UserRegInvites instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	public void update(UserRegInvites persistentInstance) {
		log.debug("update UserRegInvites instance");
		try {
			getSession().update(persistentInstance);
			log.debug("update successful");
		} catch (RuntimeException re) {
			log.error("update failed", re);
			throw re;
		}
	}

	public UserRegInvites findById(Integer id) {
		log.debug("getting UserRegInvites instance with id: " + id);
		try {
			UserRegInvites instance = (UserRegInvites) getSession().get(UserRegInvites.class, id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List<UserRegInvites> findByProperty(String propertyName, Object value) {
		log.debug("finding UserRegInvites instance with property: " + propertyName + ", value: " + value);
		try {
			String queryString = "FROM UserRegInvites as model where model." + propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
}
